package com.walkline.weibo.dao;

import java.util.Vector;

import org.json.me.JSONArray;
import org.json.me.JSONException;
import org.json.me.JSONObject;

import com.walkline.util.Function;
import com.walkline.weibo.WeiboException;
import com.walkline.weibo.WeiboSDK;
import com.walkline.weibo.inf.Tag;
import com.walkline.weibo.inf.TagWrapper;

public class WeiboTagWrapper implements TagWrapper
{
	private Vector _tags;

	public WeiboTagWrapper(WeiboSDK weibo, JSONArray jsonArray) throws WeiboException
	{
		JSONArray tagWrapper = jsonArray;
		if (tagWrapper.length() > 0)
		{
			_tags = new Vector();
			JSONObject tagObject;
			Tag tag;

			for (int i=0; i<tagWrapper.length(); i++)
			{
				try {
					tagObject = (JSONObject) tagWrapper.get(i);

					tag = new WeiboTag(weibo, tagObject);
					if (tag != null) {_tags.addElement(tag);}
				} catch (JSONException e) {Function.errorDialog(e.toString());}
			}
		}
	}

	public Vector getTags() {return _tags;}
}